//
//  ECardTemplateVC.m
//  leyitui
//
//  Created by 王大江 on 17/9/28.
//  Copyright © 2017年 xinleyi. All rights reserved.
//

#import "ECardTemplateVC.h"
#import "ECardTemplateCell.h"

static NSString* const kCellID = @"ECardTemplateCell"; // UICollectionViewCell xid

@interface ECardTemplateVC ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *mainCV;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout;



@end

@implementation ECardTemplateVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setLayoutDataByColumNum:2 space:8.0 height:280];
    
    [self.mainCV registerNib:[UINib nibWithNibName:kCellID bundle:nil] forCellWithReuseIdentifier:kCellID];
    
    
}

-(void)setLayoutDataByColumNum:(int)columnsNum space:(CGFloat)space height:(CGFloat)height {
    CGFloat sum_width = self.mainCV.frame.size.width;
    CGFloat itemWidth = (sum_width - 10 - (columnsNum-1)*space)
    / columnsNum;
    self.flowLayout.itemSize = CGSizeMake(itemWidth, height);
    
}


- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
{
    return 2;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{

    ECardTemplateCell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
    
    
    return cell;
}





@end
